package com.spring.test.service.impl;

import com.spring.test.service.ProductService;
import com.spring.test.service.UserService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class UserServiceImpl implements UserService, InitializingBean, DisposableBean {

	private ProductService productService;

	public String name;

	public UserServiceImpl(){
		System.out.println("userserviceImpl 初始化，构造函数被调用");
	}

	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	public ProductService getProductService() {
		return productService;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String getName() {
		return "name="+name;
	}

	@Override
	public void test(){
		System.out.println(productService);
	}

	@PostConstruct
	public void postConstructMethod(){
		System.out.println("userserviceImpl...postConstructMethod...");
	}

	@PreDestroy
	public void preDestroyMethod(){
		System.out.println("userserviceImpl...preDestroyMethod...");
	}

	public void initMethod(){
		System.out.println("userserviceImpl ...initMethod...");
	}

	public void destroyMethod(){
		System.out.println("userserviceImpl...destroyMethod...");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("userserviceImpl InitializingBean...afterPropertiesSet...执行了...");
	}

	@Override
	public void destroy() throws Exception {
		System.out.println("userserviceImpl DisposableBean...destroy...执行了...");
	}
}
